﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AiLuWeb.WebSite.Code;
using AiLuWeb.Model;
using AiLuWeb.Business;
using Ajeelee.Core.Utils;
using System.Collections;

namespace AiLuWeb.WebSite.WebAdmin
{
    public partial class Category : AuthPageBase
    {
        protected int pid;
        protected IList<NewsClass> newsClassList = new List<NewsClass>();
        INewsClassBusiness newsClassBll = new NewsClassBusinessFactory().CreateNewsClassBusiness();

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                pid = QueryParamInt32("pid");
                // 删除
                if (!string.IsNullOrEmpty(QueryParam("d")) && QueryParamInt32("d") > 0)
                {
                    newsClassBll.Delete(QueryParamInt32("d"));
                    newsClassBll.DeleteByPid(QueryParamInt32("d"));

                    Function.RemoveCacheObject("/cache/newsclassall/");
                    System.Threading.Thread.Sleep(500);
                    Page_GoTo(Request.UrlReferrer.AbsoluteUri.IsNotNullAndEmpty() ? Request.UrlReferrer.AbsoluteUri : "Category.aspx?pid=" + pid);
                }
                if (pid > 0)
                {
                    Hashtable ht = new Hashtable();
                    ht.Add(NewsClassHash.PId, pid);
                    newsClassList = newsClassBll.GetAllNewsClass(ht);
                }

            }
            catch (Exception ex)
            {
                Function.WriteErrorLog(ex);
            }
        }
    }
}